﻿namespace FODATAC.Interfaces

open System.Threading.Tasks
open System
open System.Collections.Generic
open System.Net
open Microsoft.Data.Edm
open System.Linq
open System.Linq.Expressions
open FODATAC.CommonTypes
open FODATAC

type IQuery = 
    abstract ToListAsync<'T> : unit -> Task<IList<'T>>
    abstract UniqueResultAsync<'T> : unit -> Task<'T>
    abstract Query : string with get
    abstract PostAsync : IEnumerable<BodyParameter> -> Task<IList<'T>>

type ISession = 
    inherit IDisposable
    abstract CommitAsync : unit -> Task
    abstract RollbackAsync : unit -> Task
    abstract CreateQuery : string -> IQuery
    abstract GetAsync : 'T -> Task<'T>
    abstract Evict : 'T -> unit
    abstract MergeAsync : 'T -> Task<'T> when 'T: equality and 'T:null
    abstract Contains : Object -> bool
    abstract FlushAsync : unit -> Task
    abstract Delete : Object -> unit
    abstract SaveAsync : Object -> Task
    abstract Query<'T> : string -> IQueryable<'T>
    abstract Query<'T> : unit -> IQueryable<'T>
    abstract SessionFactory : ISessionFactory with get
    abstract GuidKey : string with get
    abstract GetEntityUri:obj-> Uri
    abstract LoadAssociationAsync<'T, 'K when 'T : equality and 'T : null> : 'T -> Expression<Func<'T, 'K>> -> Task

and ISessionFactory = 
    abstract MetaData : MetaData with get
    abstract NetworkCredential : NetworkCredential with get
    abstract OpenSession : unit -> ISession
    abstract BaseUri : Uri with get

type IODataQueryable<'T> = 
    inherit IQueryable<'T>
    abstract ToListAsync : unit -> Task<IList<'T>>
    abstract FirstAsync : unit -> Task<'T>
    abstract FirstOrDefaultAsync : unit -> Task<'T>
